
import csv

class CSV_File:

    def update(self, data, DATA_TYPE):
        if DATA_TYPE == "COMPANYS_OZ":
            with open(r"./prediction/datasets/today_matchs_company_odds.csv", "a", encoding="gbk", newline="") as f:
                # 2. 基于文件对象构建 csv写入对象
                csv_writer = csv.writer(f)
                csv_writer.writerow(list(data))
                # 5. 关闭文件
                f.close()

        if DATA_TYPE == "TIME_SERIES_OZ":
            with open(r"./prediction/datasets/today_matchs_time_series_odds.csv", "a", encoding="gbk", newline="") as f:
                # 2. 基于文件对象构建 csv写入对象
                csv_writer = csv.writer(f)
                csv_writer.writerow(list(data))
                # 5. 关闭文件
                f.close()

            # if (os.path.exists('D:/qiutan_predict/prediction/datasets/today_matchs_company_odds.csv')):
            #     os.remove('D:/qiutan_predict/prediction/datasets/today_matchs_company_odds.csv')
            #
            # df = pd.DataFrame(list(data))






